﻿using System;

class SequenceOfGivenSum
{
    static void Main()
    {
        int[] array = { 8, 0, 3, -1, 4, 6, 1, -17, 55, 1, 10, -145, 12, -1 };
        int givenSum = 11;
        int tempSum = 0;

        for (int i = 0; i < array.Length; i++)
        {
            tempSum = 0;

            for (int k = i; k < array.Length; k++)
            {
                tempSum += array[k];

                if (tempSum == givenSum)
                {
                    Console.WriteLine("A sum of {0} is found! The elements are:", givenSum);

                    for (int j = i; j <= k; j++)
                    {
                        Console.WriteLine("[{0}] --> {1}", j, array[j]);
                    }

                    Console.WriteLine();
                }
            }
        }
    }
}
